﻿using BG.DAL.Model;
using BG.DAL.Context;
using System.Collections.Generic;
using System;
using System.Data;
using System.Data.Entity;
using System.Linq;

namespace BG.DAL.SQLDAL
{
    public class RoleUsersManager
    {
        public static RoleUser GetById(Guid id)
        {
            using (DataContext db = new DataContext())
            {
                RoleUser Model = db.RoleUsers.Find(id);
                return Model;
            }
        }

        public static void Create(RoleUser model)
        {
            using (DataContext db = new DataContext())
            {
                db.RoleUsers.Add(model);
                db.SaveChanges();
            }
        }

        public static void Edit(RoleUser model)
        {
            using (DataContext db = new DataContext())
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
            }
        }

        public static void Delete(RoleUser id)
        {
            using (DataContext db = new DataContext())
            {
                RoleUser model = db.RoleUsers.Find(id);
                db.RoleUsers.Remove(model);
                db.SaveChanges();

            }
        }

    }
}